import type { Rule } from 'ant-design-vue/es/form'

/**
 * 表单项类型
 */
export enum FormItemType {
  INPUT = 'input',
  INPUT_PASSWORD = 'input-password',
  INPUT_NUMBER = 'input-number',
  TEXTAREA = 'textarea',
  SELECT = 'select',
  TREE_SELECT = 'tree-select',
  RADIO_GROUP = 'radio-group',
  CHECKBOX_GROUP = 'checkbox-group',
  SWITCH = 'switch',
  DATE_PICKER = 'date-picker',
  RANGE_PICKER = 'range-picker',
  UPLOAD = 'upload',
  SLOT = 'slot',
  ROW = 'row'
}

/**
 * 表单项配置接口
 */
export interface FormItemConfig {
  field?: string
  label?: string
  type: FormItemType
  value?: any
  rules?: Rule[]
  placeholder?: string | string[]
  options?: Array<{ label: string; value: any; disabled?: boolean }>
  treeData?: any[]
  condition?: boolean | ((formData: Record<string, any>) => boolean)
  help?: string
  props?: Record<string, any>
  span?: number
  xs?: number
  sm?: number
  md?: number
  lg?: number
  xl?: number
  slotName?: string
  disabled?: boolean
  min?: number
  max?: number
  step?: number
  rows?: number
  allowClear?: boolean
  mode?: string
  fieldNames?: Record<string, string>
  children?: FormItemConfig[]
}

/**
 * 表单行项配置接口
 */
export interface FormRowItem extends Omit<FormItemConfig, 'field' | 'value'> {
  type: FormItemType.ROW
  gutter?: number
  children: FormItemConfig[]
} 